package com.web.ShoppingDemo.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.web.ShoppingDemo.model.Forder;
import com.web.ShoppingDemo.model.Status;
import com.web.ShoppingDemo.model.User;

@Controller
@Scope("prototype")
public class ForderAction extends BaseAction<Forder>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 重写Model接受参数
	 */
	@Override
	public Forder getModel() {
		model = (Forder)session.get("forder");
		return model;
	}
	
	/**
	 * 完成订单的级联入库 的功能
	 * @return
	 */
	public String save(){
		//把session中的购物项,交给model
		User user = (User)session.get("user");
		model.setUser(user);
		model.setStatus(new Status(1));
		
		//级联入库(xml配置)
		forderService.save(model);
		
		session.put("oldForder", session.get("forder"));
		//订单入库,session清空
		session.put("forder", new Forder());
		
		return "bank";
	}
	
}
